In this video we will learn some very helpful daytime indexed methods and attributes and with these
methods and attributes you can for example create additional features for what data frame containing
some kind of customized the representation of date or time.
So let's first of all import pandas and we import our stocks.
CSC and we set the date column as being the date time index.
So let's have a look here and then we only selected the opening prices for our six stocks and we are
creating a copy and start a new data frame and the variable clothes.
So let's have a look here.
So this is our close data frame with daily closing prices for our six stocks.
And it's also called here the info method and we can see here that we have a daytime index with actually
a daily timestamps and with the index attribute we can also have a closer look at our day time index.
So here we have the daytime index to the timestamps.
So in total we have two thousand two hundred and ninety Daily Times stems.
And here we can see for example for one time stamp.
So here we have the fourth of January 2010.
And it might be quite helpful to get you additional information or different representation of the date.
So for example it might be useful to have the day off the week.
So for example Tuesday or Wednesday or the quarter of the year.
So here in this example it's the first quarter and we can do this with quite a head for attributes and
methods on the index.
So first of all we FCB they attribute and we get actually the day of the month.
So for example in our first time stamp we have for the thirty first of December and here we get the
thirty first.
So that data types see an integer and consequently we get you for the other timestamps for example here
for 10 we get 5 and so on and we can also get an integer representation of the month and we can do this
for the month at tribute.
So here we have the data type in the data and we get twelve here for the timestamp in December and one
for the time stamps in January and so on Next we can also get the year with the year attribute.
So here again we have integer data types.
2009 2010 and so on.
And for each row off each time stamp and our data frame we can also get to the day of the week or the
day name with the method day name so here we have a Thursday Monday Tuesday and so on and we can actually
do the very same with the attribute week name all week day name and typical actually the same week day
names and also instead of getting an integer representation of the month.
So here twelve one 2 Three you can get the month name so you have with the method the month name and
t we get.
December January February and so on.
So next we have to attribute to weekday and instead of getting here the string representation first
day Monday Tuesday we get an intense representation so zero stands for Monday.
Then one stands for Tuesday and so on and we can also get the quarter with the quarter attribute and
by default the first quarter is from January to March the second from April to June and so on.
So we can see for the time stamp in December we get a far and for the time stamps and January a one
as in the jar.
Then next we have also the attributed days and month and TV get for each row off each time stamp the
amount of days in the respective month.
So in December we have 31 and January 31 and so on and next that s also the week at tribute and TV we
get actually the calendar week saw the very last week in December as the week fifty.
Then the very first week in January is the week 1 and so on and the same we can actually get with the
attribute week off year.
So this is the same and that's another attribute court is month and and year pen us checks for each
row of each time stem whether the day is actually the very last day of the month.
So here we have for the thirty first of December a true.
And for the 1st of January or for the second a fourth.
So these are some very helpful attributes and methods on the daytime index and that even more methods
so feel free to have a closer look.
And now we can also create new columns and new features for our data frame.
So for example we want to have the day name as the new feature and we can create yet a new column called
day.
And we want to have the quarter as the new column on your feet.
So let's do this here and let's have a look here at our new data frame.
So here we have our adjusted close that frame where we have you on the right hand side.
The two additional columns day and quarter and year for each row off each timestamp we have here the
weekday day and the quarter.
So creating additional features with different representation of date might be in some cases quite helpful.
And with this we are finished now.
And I hope to see you also in the next video by.